import java.util.Scanner;

public class Solution {
    public boolean isUgly(int n) {
        if(n <= 0){
            return false;
        }
        int[] prime = new int[]{2,3,5};
        for (int i = 0; i < prime.length; i++) {
            while(n % prime[i] == 0){
                n/= prime[i];//对n反复除以2、3、5
            }
        }
        return n==1;//如果最后结果等于1，则是丑数；如果还有其它质因数，则不是丑数
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int num = in.nextInt();
            Solution solution = new Solution();
            boolean result = solution.isUgly(num);
            System.out.println(result);
        }
    }
}
